package team.future.joke.service.impl;

import static org.springframework.data.mongodb.core.query.Criteria.where;
import static org.springframework.data.mongodb.core.query.Query.query;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import team.future.joke.dao.BaseMongoDao;
import team.future.joke.entity.JokeLike;
import team.future.joke.service.JokeLikeService;

/**
 * Title: JokeStoreServiceImpl.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月13日 上午11:16:46 <br>
 * @author futurezhu
*/
@Service("jokeLikeService")
public class JokeLikeServiceImpl implements JokeLikeService {

	@Autowired
	private BaseMongoDao<JokeLike> jokeLikeDao;

	@Override
	public void insertLike(JokeLike like) {
		jokeLikeDao.insertObject(like);
	}

	@Override
	public void deleteLike(String jokeId, String uid) {
		jokeLikeDao.deleteObject(query(where("jokeId").is(jokeId).and("uid").is(uid)));
	}

	@Override
	public List<JokeLike> getJokeLikes(String uid) {
		return jokeLikeDao.getObjectList(query(where("uid").is(uid)));
	}

}
